package com.system.zuul.service;

import com.system.zuul.dao.ApiKeyDao;
import com.system.zuul.model.ApiKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApiKeyService {
    @Autowired
    ApiKeyDao apiKeyDao;

    public ApiKey getApiKey(String key){
        if(apiKeyDao.getApiKeyCount(key).equals(0)){
            return null;
        }else {
            return apiKeyDao.getApiKey(key);
        }
    }

    public Integer getApiKeyCount(String key){
        return apiKeyDao.getApiKeyCount(key);
    }

    public Integer addRequestCount(String key){
        return apiKeyDao.addRequestCount(key);
    }
}
